/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.agenda.model.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ronildo
 */
@Entity
@Table(name = "AM_TB_PACI")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AmTbPaci.findAll", query = "SELECT a FROM AmTbPaci a"),
    @NamedQuery(name = "AmTbPaci.findByCdUsuaPaci", query = "SELECT a FROM AmTbPaci a WHERE a.cdUsuaPaci = :cdUsuaPaci"),
    @NamedQuery(name = "AmTbPaci.findByNmPaci", query = "SELECT a FROM AmTbPaci a WHERE a.nmPaci = :nmPaci"),
    @NamedQuery(name = "AmTbPaci.findByNrCpf", query = "SELECT a FROM AmTbPaci a WHERE a.nrCpf = :nrCpf"),
    @NamedQuery(name = "AmTbPaci.findByDtNasc", query = "SELECT a FROM AmTbPaci a WHERE a.dtNasc = :dtNasc"),
    @NamedQuery(name = "AmTbPaci.findByNrEndeResi", query = "SELECT a FROM AmTbPaci a WHERE a.nrEndeResi = :nrEndeResi"),
    @NamedQuery(name = "AmTbPaci.findByDsCompEnde", query = "SELECT a FROM AmTbPaci a WHERE a.dsCompEnde = :dsCompEnde"),
    @NamedQuery(name = "AmTbPaci.findByDtCada", query = "SELECT a FROM AmTbPaci a WHERE a.dtCada = :dtCada")})
public class AmTbPaci implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @Basic(optional = false)
    @Column(name = "CD_USUA_PACI")
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "seq_AM_TB_PACI")
    @SequenceGenerator(name="seq_AM_TB_PACI", sequenceName = "seq_AM_TB_PACI")
    private Integer cdUsuaPaci;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 40)
    @Column(name = "NM_PACI")
    private String nmPaci;
    @Basic(optional = false)
    @NotNull
    @Column(name = "NR_CPF")
    private long nrCpf;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DT_NASC")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dtNasc;
    @Basic(optional = false)
    @NotNull
    @Column(name = "NR_ENDE_RESI")
    private int nrEndeResi;
    @Size(max = 30)
    @Column(name = "DS_COMP_ENDE")
    private String dsCompEnde;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DT_CADA")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dtCada;
    @OneToMany(mappedBy = "cdUsuaPaci")
    private Collection<AmTbAgenMedi> amTbAgenMediCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "amTbPaci")
    private Collection<AmTbTelePaci> amTbTelePaciCollection;
    @JoinColumn(name = "CD_USUA_PACI", referencedColumnName = "CD_USUA", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private AmTbUsuaSist amTbUsuaSist;
    @JoinColumn(name = "CD_CEP", referencedColumnName = "CD_CEP")
    @ManyToOne(optional = false)
    private AmTbLogr cdCep;

    public AmTbPaci() {
    }

    public AmTbPaci(Integer cdUsuaPaci) {
        this.cdUsuaPaci = cdUsuaPaci;
    }

    public AmTbPaci(Integer cdUsuaPaci, String nmPaci, long nrCpf, Date dtNasc, int nrEndeResi, Date dtCada) {
        this.cdUsuaPaci = cdUsuaPaci;
        this.nmPaci = nmPaci;
        this.nrCpf = nrCpf;
        this.dtNasc = dtNasc;
        this.nrEndeResi = nrEndeResi;
        this.dtCada = dtCada;
    }

    public Integer getCdUsuaPaci() {
        return cdUsuaPaci;
    }

    public void setCdUsuaPaci(Integer cdUsuaPaci) {
        this.cdUsuaPaci = cdUsuaPaci;
    }

    public String getNmPaci() {
        return nmPaci;
    }

    public void setNmPaci(String nmPaci) {
        this.nmPaci = nmPaci;
    }

    public long getNrCpf() {
        return nrCpf;
    }

    public void setNrCpf(long nrCpf) {
        this.nrCpf = nrCpf;
    }

    public Date getDtNasc() {
        return dtNasc;
    }

    public void setDtNasc(Date dtNasc) {
        this.dtNasc = dtNasc;
    }

    public int getNrEndeResi() {
        return nrEndeResi;
    }

    public void setNrEndeResi(int nrEndeResi) {
        this.nrEndeResi = nrEndeResi;
    }

    public String getDsCompEnde() {
        return dsCompEnde;
    }

    public void setDsCompEnde(String dsCompEnde) {
        this.dsCompEnde = dsCompEnde;
    }

    public Date getDtCada() {
        return dtCada;
    }

    public void setDtCada(Date dtCada) {
        this.dtCada = dtCada;
    }

    @XmlTransient
    public Collection<AmTbAgenMedi> getAmTbAgenMediCollection() {
        return amTbAgenMediCollection;
    }

    public void setAmTbAgenMediCollection(Collection<AmTbAgenMedi> amTbAgenMediCollection) {
        this.amTbAgenMediCollection = amTbAgenMediCollection;
    }

    @XmlTransient
    public Collection<AmTbTelePaci> getAmTbTelePaciCollection() {
        return amTbTelePaciCollection;
    }

    public void setAmTbTelePaciCollection(Collection<AmTbTelePaci> amTbTelePaciCollection) {
        this.amTbTelePaciCollection = amTbTelePaciCollection;
    }

    public AmTbUsuaSist getAmTbUsuaSist() {
        return amTbUsuaSist;
    }

    public void setAmTbUsuaSist(AmTbUsuaSist amTbUsuaSist) {
        this.amTbUsuaSist = amTbUsuaSist;
    }

    public AmTbLogr getCdCep() {
        return cdCep;
    }

    public void setCdCep(AmTbLogr cdCep) {
        this.cdCep = cdCep;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cdUsuaPaci != null ? cdUsuaPaci.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AmTbPaci)) {
            return false;
        }
        AmTbPaci other = (AmTbPaci) object;
        if ((this.cdUsuaPaci == null && other.cdUsuaPaci != null) || (this.cdUsuaPaci != null && !this.cdUsuaPaci.equals(other.cdUsuaPaci))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.agenda.model.entity.AmTbPaci[ cdUsuaPaci=" + cdUsuaPaci + " ]";
    }
    
}
